<?php

namespace App\Admin\Actions\Post;


use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;

class ChangePrice extends RowAction
{
    public $name = '修改价格';

    public function handle(Model $model,Request $request)
    {


        $model->old_money = $model->money;
        $model->money = $request->get('money');
        $model->price_note = $request->get('price_note');

        $res = $model->save();

        if($res)
            return $this->response()->success('修改成功')->refresh();


        return $this->response()->error('修改失败')->refresh();


    }


//    public function dialog()
//    {
//        $this->confirm('确定退款？');
//    }

    public function form(Model $model){
        $this->text('money','修改价格');
        $this->text('price_note','修改备注');
    }

}
